﻿using System.Collections.Generic;

namespace Model
{
	public abstract class Expression
	{
		private string expressionString;
		public string ExpressionString
		{
			get { return expressionString; }
			set { expressionString = value; }
		}
		private List<CauseExpression> causes;
		public List<CauseExpression> Causes
		{
			set { causes = value; }
			get { return causes; }
		}
		protected CellDefinition cellDefinition;
		public CellDefinition CellDefinition
		{
			get { return cellDefinition; }
			set { cellDefinition = value; }
		}

		protected Cell cellEvaluate;
		public Cell EvaluationCell
		{
			get { return cellEvaluate; }
			set { cellEvaluate = value; }
		}

		abstract public bool evaluate(Cell zelle);

		public bool and(Expression rightSide)
		{
			if (this.evaluate(cellEvaluate) && rightSide.evaluate(cellEvaluate))
				return true;
			else
				return false;
		}

		public bool or(Expression rightSide)
		{
			if (this.evaluate(cellEvaluate) || rightSide.evaluate(cellEvaluate))
				return true;
			else
				return false;
		}

		public bool xor(Expression rightSide)
		{
			if ((this.evaluate(cellEvaluate) && !rightSide.evaluate(cellEvaluate)) || (!this.evaluate(cellEvaluate) && rightSide.evaluate(cellEvaluate)))
				return true;
			else
				return false;
		}

		public bool definedFor(CellDefinition checkZelle)
		{
			if (checkZelle.Name.Equals(checkZelle.Name))
				return true;
			else
				return false;
		}
	}
}
